package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.DestinationManageOperate;

public class DestinationManageProcess {

    DriverBase driver;
    DestinationManageOperate dmh;
    public DestinationManageProcess(DriverBase driver){
        this.driver = driver;
        dmh = new DestinationManageOperate(driver);
    }

    //添加目的地
    public void addDestination(String destinationName){
        //点击基础数据管理菜单
        dmh.clickBaseDataManageMenu();
        //点击目的地管理菜单
        dmh.clickDestinationManageMenu();

        //点击添加按钮
        dmh.clickAddDestiBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //输入目的地名称
        dmh.inputDestiName(destinationName);

        //点击分类
        dmh.clickDestiCate();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //选择分类
        dmh.selectCategory();

        //点击关联目的“选择”按钮
        dmh.clickSelectBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //双击选择“北京市”
        dmh.doubleClickBJoption();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击确定
        dmh.clickSelectOptiConfriBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击添加缩略图按钮
        dmh.clickAddThumbnailBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //上传缩略图
        dmh.execAddImgScript();
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //点击确认按钮
        dmh.clickAddThumbConfirmBtn();

    }


    //断言
    public boolean addDestinationSuccess(String destinationName){
        if(dmh.getFirstDestiName().getText().contains(destinationName)){
            return true;
        }
        else {
            return false;
        }
    }


    //查询目的地
    public void searchDestination(){
        //点击状态下拉框
        dmh.clickStatusDownList();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //选择状态
        dmh.selectStatus();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //点击分类下拉框
        dmh.clickCategoryDownList();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //选择分类
        dmh.selectSearchCategory();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //d点击搜索
        dmh.clickSearchBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    //断言
    public boolean searchSuccess(){
        if(dmh.getSearchResultList().size()>0){
            return true;
        }
        else {
            return false;
        }

    }


}
